package com.code.test.second;

import java.io.File;
import java.io.IOException;

public class LeetCodeStat {

    public static void main(String[] args) throws IOException {
        final File folder = new File(LeetCodeStat.class.getResource(".").getPath());
        int codeCount = listFilesForFolder(folder);
        System.out.println("已累计刷题：" + codeCount);
    }

    public static int listFilesForFolder(final File folder) throws IOException {
        int codeCount = 0;
        for (final File fileEntry : folder.listFiles()) {
            if (fileEntry.isDirectory()) {
                codeCount += listFilesForFolder(fileEntry);
            } else {
//                System.out.println(fileEntry.getCanonicalPath().toString() + "." + fileEntry.getName());
                codeCount++;
            }
        }
        return codeCount;
    }
}
